Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

353
Visualizações
Angular - How to call ngOnDestroy when change [src] in iFrame

I have one slide show application that support only many internal link.

HTML

<iframe width="100%" id="iframeSlide" height="100%" #iframe frameBorder="0" [src]="urlSafe"></iframe>

TS code

current.urlSafe = current.sanitizer.bypassSecurityTrustResourceUrl(current.slideUrls[current.index]);

slideUrls is an array contains list of internal link, but when new url set to current.urlSafe, the old url did not call ngOnDestroy function to release resource.

I tried to set current.urlSafe = "about:blank";

or

var frame = document.getElementById("iframeSlide"),
frameDoc = frame.contentDocument || frame.contentWindow.document;
frameDoc.removeChild(frameDoc.documentElement);

But it did not call ngOnDestroy function. In the internal page, I used setInterval function so need go to ngOnDestroy to clear the Interval, without it many request to called inside setInterval.

Links I refereed

https://web.dev/detached-window-memory-leaks/

How do I clear all intervals?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Changing the iframe src would be the equivalent to navigating to a new url in the browser address bar. The browser itself clears the top level JS/HTML resources in this case

ngOnDestroy would occur if you remove components or services within the app, but not on a refresh

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda